package com.acme.bankapp.domain.bank;

/**
 * Account operating with own balance + overdraft. Balance can be negative.
 */
public class CheckingAccount extends AbstractAccount {

    private double overdraftLimit;

    /**
     * Constructs checking account
     * @param amount Initial balance
     * @param overdraftLimit Overdraft limit
     */
    public CheckingAccount(double amount, double overdraftLimit){
        super(amount);
        this.overdraftLimit = overdraftLimit;
    }

    /**
     * @return overdraftLimit limit
     */
    public double getOverdraftLimit() {
        return overdraftLimit;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public double maximumAmountToWithdraw() {
        return getBalance() + overdraftLimit > 0 ? getBalance() + overdraftLimit : 0;
    }
}
